#-*- encoding: utf8 -*-

import pygtk
pygtk.require('2.0')
import gtk

def message(text, dialog= None):
        """
        Usage: message(text, dialog)
        text   ->		text to be shown on pango dafaults
        dialog ->		active dialog 
        
        Shows a dialog with one button 'OK', with the provided text

        Pango references:
        http://www.pygtk.org/pygtk2reference/pango-markup-language.html
        """

        dialog= gtk.MessageDialog(dialog, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, text)
        dialog.set_markup(text)
        dialog.run()
        dialog.destroy()

def message_error(text, dialog= None):
        """
        Usage: message(text, dialog)
        text   ->		text to be shown on pango dafaults
        dialog ->		active dialog 
        
        Shows a dialog with one button 'OK', with the provided text

        Pango references:
        http://www.pygtk.org/pygtk2reference/pango-markup-language.html
        """

        dialog= gtk.MessageDialog(dialog, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
        dialog.set_markup(text)
        dialog.run()
        dialog.destroy()

def confirm(text, dialog= None):
        """
        Usage: confirm(text, dialog)
        text   ->		text to be shown on pango dafaults
        dialog ->		active dialog 
        

        Shows a dialog with two buttons 'Yes' and 'No',
        with the provided text.
        
        Pango references:
        http://www.pygtk.org/pygtk2reference/pango-markup-language.html
        """

        dialog= gtk.MessageDialog (dialog, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, text)
        dialog.set_markup(text)
        response = dialog.run ()
        dialog.destroy ()
        if response == gtk.RESPONSE_YES:
                return True
        else:
                return False
